package com.lius.SpringBootStart.handler;

import com.lius.SpringBootStart.utils.JsonData;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局异常处理handle
 */
@RestControllerAdvice
public class CustomExHandler {

    @ExceptionHandler(value = Exception.class)
    JsonData handleException(Exception e, HttpServletRequest request){
        return JsonData.buildError("服务器端处理异常：" + e.getMessage(),-7700);
    }
}
